package org.spring.data.jpa.demo.config;

import com.p6spy.engine.spy.appender.MessageFormattingStrategy;

import java.time.LocalDateTime;

/**
 * @date 2021/9/6
 * @auther uranus
 */
public class P6spyLogger implements MessageFormattingStrategy {

    @Override
    public String formatMessage(int connectionId, String now, long elapsed,
                                String category, String prepared, String sql,
                                String url) {
        return !"".equals(sql.trim()) ? "[ " + LocalDateTime.now() + " ] --- " +
                "| took "
                + elapsed + "ms | " + category + " | connection " + connectionId + "\n "
                + sql + ";" : "";
    }
}
